﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_JYZX_JianYiZiXun : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateDrop();
        }
        txtADdUserID.Attributes.Add("ReadOnly", "true");
    }

    // 铺下拉框数据
    public void PopulateDrop()
    {
        drpWTLX.PopulateFromEnum<JYZX.type>();
        drpWTLX.Items.Insert(0, new ListItem("请选择", "0"));
    }

    // 铺数据
    public void PopulateJYZX()
    {
        lvDate.DataSource = JYZX.GetAllByConditon(DongDong.Common.Misc.ConvertToInt(drpWTLX.SelectedValue), txtAddTimeFrom.Text, txtAddTimeTo.Text, DongDong.Common.Misc.ConvertToInt(hdlAddUserID.Value));
        lvDate.DataBind();
    }

    // 查询显示用户基本信息
    public string GetUserName(object UserID)
    {
        string Return = "暂无资料";
        Client objClient = Client.Get(DongDong.Common.Misc.ConvertToInt(UserID));
        if (objClient != null)
        {
            Return = "<a target='_blank' href='../../Admin/Client/Add.aspx?UserID='" + objClient.ID + ">" + objClient.Username + "</a>";
        }
        return Return;
    }

    // 翻页
    protected void Pager_PreRender(object sender, EventArgs e)
    {
        PopulateJYZX();
    }

    // 删除记录
    protected void lvDate_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        int KeyID = DongDong.Common.Misc.ConvertToInt(lvDate.DataKeys[e.ItemIndex].Value);
        JYZX.Delete(KeyID);
        lvDate.EditIndex = -1;
        PopulateJYZX();
    }

    protected void lvDate_PagePropertiesChanged(object sender, EventArgs e)
    {
        PopulateJYZX();
    }
}